#include<stdio.h>

int main()
{
	int a[]={900,500,400,100,90,50,40,10,9,5,4,1};
	char s[]={"CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
	char b=" ";
	int i,num;
	scanf("%d",&num);
	for (i=0;i<12;i++)
	{
		while (num>=a[i])
		{
			num=num-a[i];
			b+=s[i];
		}
	}
	printf("%s\n",b); 
	return 0;
}
